/*
 * @Author: luodongming
 * @Date: 2019-05-17 16:56:02
 * @LastEditors: Bingo
 * @Email: ldm920@163.com
 * @LastEditTime: 2024-09-02 15:23:01
 */
const getters = {
    device: (state: { app: { device: any; }; }) => state.app.device,
    theme: (state: { app: { theme: any; }; }) => state.app.theme,
    color: (state: { app: { color: any; }; }) => state.app.color,
    token: (state: { user: { token: any; }; }) => state.user.token,
    avatar: (state: { user: { avatar: any; }; }) => state.user.avatar,
    //nickname: state => state.user.userType,
    nickname: (state: { user: { userType: string; login: any; name: any; }; }) => {
      if(state.user.userType && "SUPPLIER"===state.user.userType){
        return state.user.login;
      }else{
        return state.user.name;
      }
    },
    login: (state: { user: { login: any; }; }) => state.user.login,
    deptInfo: (state: { user: { deptInfo: any; }; }) => state.user.deptInfo,
    deptList: (state: { user: { deptList: any; }; }) => state.user.deptList,
    welcome: (state: { user: { welcome: any; }; }) => state.user.welcome,
    roles: (state: { user: { roles: any; }; }) => state.user.roles,
    hasAnyRoles: (state: { user: { roles: string | string[]; }; }) => (roleCodes: string | any[]) =>　{
      for (let i = 0; i < roleCodes.length; i++) {
        if (state.user.roles.includes("ROLE_" + roleCodes[i])) {
          return true;
        }
      }
      return false;
    },
    userInfo: (state: { user: { info: any; }; }) => state.user.info,
    pageAuths: (state: { user: { pageAuths: any; }; }) => state.user.pageAuths,
    addRouters: (state: { permission: { addRouters: any; }; }) => state.permission.addRouters,
    multiTab: (state: { app: { multiTab: any; }; }) => state.app.multiTab,
    sidebar: (state: { app: { sidebar: any; }; }) => state.app.sidebar,
    LogoutKey: (state: { app: { key: any; }; }) => state.app.key,
   
    userMenu: (state: { user: { userMenu: any; }; }) => state.user.userMenu,
    resDetail: (state: { app: { resDetail: any; }; }) => state.app.resDetail,
    pageSkipping: (state: { app: { pageSkipping: any; }; }) => state.app.pageSkipping,
    dicObj: (state: { app: { dicObj: any; }; }) => state.app.dicObj,
    dicLimitObj: (state: { app: { dicLimitObj: any; }; }) => state.app.dicLimitObj,
    userAuths: (state: { user: { userAuths: any; }; }) => state.user.userAuths,
    showLogin: (state: { user: { isShowLogin: any; }; }) => state.user.isShowLogin,
  
  };
  
  export default getters;